<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">撞库统计</ui:define>
    <ui:define name="content">
    
    

        <h:form>
            <p:dialog header="操作执行中,请稍候" widgetVar="doing" modal="true" closable="false" resizable="false" draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         rendered="#{checkUserStatBean.isNormal()}"
                                         update="@form"/>
                        <p:commandButton value="导出" ajax="false" icon="ui-icon-arrowthick-1-s">
					        <p:fileDownload value="#{checkUserStatBean.downloadExcel()}" />
					    </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;text-align:center;">
                                <p:outputLabel for="startDate" value="开始时间"/>
                                <p:calendar id="startDate" value="#{checkUserStatBean.$.startDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="endDate" value="结束时间"/>
                                <p:calendar id="endDate" value="#{checkUserStatBean.$.endDate}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"/>

                                <p:outputLabel for="selectProduct" value="产品（多选）"/>
                                <p:selectCheckboxMenu id="selectProduct" value="#{checkUserStatBean.$.products}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems value="#{checkUserStatBean.productList}" var="product"
                                                   itemValue="#{product.prdid}" itemLabel="#{product.name}(#{product.prdid})"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="selectChannel" value="渠道（多选）"/>
                                <p:selectCheckboxMenu id="selectChannel" value="#{checkUserStatBean.$.channels}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItems value="#{checkUserStatBean.channelList}" var="channel"
                                                   itemValue="#{channel.channel_code}" itemLabel="#{channel.channel_name}(#{channel.channel_code})"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="selectPlatform" value="平台（多选）"/>
                                <p:selectCheckboxMenu id="selectPlatform" value="#{checkUserStatBean.$.platforms}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItems value="#{checkUserStatBean.platformList}" var="platform"
                                                   itemValue="#{platform.platformCode}" itemLabel="#{platform.platformName}"/>
                                </p:selectCheckboxMenu>

                                <p:outputLabel for="selectUserType" value="用户类型"/>
                                <p:selectCheckboxMenu id="selectUserType" value="#{checkUserStatBean.$.types}"
                                                      updateLabel="true" multiple="true" filter="true">
                                    <f:selectItem itemLabel="- 全部 -" itemValue="-1000" noSelectionOption="true"/>
                                    <f:selectItem itemLabel="新用户" itemValue="1"/>
                                    <f:selectItem itemLabel="老用户" itemValue="0"/>
                                </p:selectCheckboxMenu>


                                <p:outputLabel for="selectActivity" value="选择活动（多选）"/>
                                <p:selectCheckboxMenu id="selectActivity" value="#{checkUserStatBean.$.hitType}"
                                                      updateLabel="true" multiple="true" filter="true" filterMatchMode="contains">
                                    <f:selectItem itemLabel="- 全部 -" itemValue="-1000"/>
                                    <f:selectItems
                                            value="#{checkUserStatBean.dictionaries[DictionaryCode.NEW_COLLISION_API_ID]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectCheckboxMenu>


                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="statisticRecordDataTable"
                                         style="width: 100%;text-align:center"
                                         var="statisticRecord"
                                         value="#{checkUserStatBean.lazyDataModel}"
                                         rows="20"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         selection="#{checkUserStatBean.selectedRecords}"
                                         resizableColumns="true">
                                <p:column headerText="时间">
                                    <h:outputText value="#{statisticRecord.time}"/>
                                </p:column>
                                <p:column headerText="产品" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.product}"/>
                                </p:column>
                                <p:column headerText="渠道" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.channel}"/>
                                </p:column>
                                <p:column headerText="平台" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.platform}"/>
                                </p:column>
                                <p:column headerText="用户类型" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.type}"/>
                                </p:column>
                                <p:column headerText="撞库id" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.ids}"/>
                                </p:column>
                                <p:column headerText="活动" style="text-align:center;">
                                    <h:outputText value="#{checkUserStatBean.translate(DictionaryCode.NEW_COLLISION_API_ID,statisticRecord.activity)}"/>
                                </p:column>
                                <p:column headerText="新用户人次" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.check_new}"/>
                                </p:column>
                                <p:column headerText="撞库人次" style="text-align:center;">
                                    <h:outputText value="#{statisticRecord.check_success}"/>
                                </p:column>
                                <p:column headerText="新用户占比">
                                    <h:outputText
                                            value="#{statisticRecord.check_new == null ?'-': statisticRecord.check_new/statisticRecord.check_success}">
                                        <f:convertNumber pattern="##,##00.00%"/>
                                    </h:outputText>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>